#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5+10;
const int mod = 998244353;
ll a,b;
ll fp(ll x,ll y) {
	ll ret = 1;
	while(y > 0) {
		if(y&1) ret = ret * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return ret;
}
ll n,m;
ll C(ll x,ll y) {
	ll ret = 1;
	for(int i = 0; i < y; i++) {
		ret = ret * (x-i) % mod * fp(i+1,mod-2) % mod;
	}
	return ret;
}
ll A(ll x,ll y) {
	ll ret = 1;
	for(int i = 0; i < y; i++) {
		ret = ret * (x-i) % mod;
	}
	return ret;
}
int main() {
	freopen("clown.in","r",stdin);
	freopen("clown.out","w",stdout);
	cin >> m; n = 1;
	for(int i = 1,x; i <= m; i++) {
		cin >> x; n = n * x;
	} 
	cin >> a >> b;
	ll x = A(a,3),y = A(b,3);
//	cout<<x<<' '<<y<<'\n';
	ll ans = (x * fp(b,n*(n-1)/2) + y * fp(a,n) - x*y) % mod + mod;
	ans = (ans + (A(a,2) * A(b,2) % mod * 6 % mod)) % mod;
	cout<<ans%mod<<'\n';
	return 0;
}
/*

*/

